package cn.wildfire.chat.app.extendsion.ui;

import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import cn.wildfire.chat.app.main.PushMessageActivity;

/**
 * Create by HEKE, 2019/8/24 16:28
 * TODO 推送发送通知广播
 */
public class PushNotifyBroadcastReceiver extends BroadcastReceiver {

    /**
     * 推送发送捕捉动作
     */
    public static final String SEND_ACTION = "chat.cailiao.push.send";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(SEND_ACTION)) {
            String msg = intent.getStringExtra("msg");
            KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
            if (km.isKeyguardLocked()) {
                Intent alarmIntent = new Intent(context, PushMessageActivity.class);
                alarmIntent.putExtra("msg", msg);
                alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(alarmIntent);
            }
        }
    }

}
